package org.itboys.core.controller.web;

import com.wordnik.swagger.annotations.Api;
import org.itboys.core.entity.mongo.SundayMember;
import org.itboys.core.service.mongo.web.SundayMemberService;
import org.itboys.framework.query.JsonPageUtils;
import org.itboys.framework.spring.controller.BaseController;
import org.itboys.param.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 作者：zzq
 * 时间：2018/10/26
 * 描述：用户
 */
@Controller
@RequestMapping("/sunday/web/member")
@Api(value = "member", description = "用户")
public class SundayMemberController extends BaseController {
    @Autowired
    private SundayMemberService memberService;
    /**
     * 用户  主页
     *
     * @param request
     * @return
     */
    @RequestMapping("/index")
    public String index(HttpServletRequest request) {
        return "/sunday/member/index";
    }

    /**
     * 分页用户信息
     *
     * @param request
     * @param response
     */
    @RequestMapping("/select")
    public void select(
            HttpServletRequest request,
            HttpServletResponse response
    ) {
        PageResult<SundayMember> result = memberService.select(request);
        JsonPageUtils.renderJsonPage(result.getTotal(), result.getData(), response);
    }

}
